package vboot.app.module.te.allot.param;

import vboot.core.common.api.R;
import vboot.core.common.dao.Sqler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("te/allot/param")
public class TeAllotParamApi {

    @GetMapping
    public R get(String name, String modid) {
        Sqler sqler = new Sqler("te_allot_param");
        sqler.addLike("t.name", name);
        return R.ok(service.findPageData(sqler));
    }

    @GetMapping("one/{id}")
    public R getOne(@PathVariable String id) {
        TeAllotParam main = service.findOne(id);
        return R.ok(main);
    }

    @GetMapping("screens")
    public R screens(String id) {
        return R.ok(service.findData(id));
    }

    @PostMapping
    public R post(@RequestBody TeAllotParam main) {
        return R.ok(service.insert(main).getId());
    }

    @PutMapping
    public R put(@RequestBody TeAllotParam main) {
        return R.ok(service.update(main).getId());
    }

    @DeleteMapping("{ids}")
    public R delete(@PathVariable String[] ids) {
        return R.ok(service.delete(ids));
    }

    @Autowired
    private TeAllotParamService service;

}
